// LibraryDB.cpp: implementation of the LibraryDB class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Library.h"
#include "LibraryDB.h"
#include <cassert>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

const CString LibraryDB::STR_DNS = "ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};UID=sa;PWD=;DBQ=Library.mdb";
LibraryDB * LibraryDB::pcInstance = NULL;

LibraryDB::LibraryDB()
{
}

LibraryDB::~LibraryDB()
{
	CDatabase::Close();
}

LibraryDB* LibraryDB::Instance()
{
	if (NULL != pcInstance) {
		return pcInstance;
	}

	pcInstance = new LibraryDB;
	assert(pcInstance != NULL);
	pcInstance->Open(NULL, false, false, STR_DNS);
	return pcInstance;
}

void LibraryDB::Destory()
{
	delete pcInstance;
	pcInstance = NULL;
}
